package com.example.reflec;

import org.springframework.util.ReflectionUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author: orange
 * @create: 2023-08-21 15:04
 * @description:
 */
public class Main {
    public static void main(String[] args) throws IllegalAccessException {
//        Class<Reflexx> reflexxClass = Reflexx.class;
//        Reflexx reflexx = new Reflexx();
//        List<List<String>> lists = reflexx.getNa();
//        List<String> strings = new ArrayList<>();
//        strings.add("xxxxxxxx");
//        strings.add("xxxxxxxx");
//        strings.add("xxxxxxxx");
//        lists.add(strings);
//
//        Field field = ReflectionUtils.findField(reflexxClass, "na");
//        field.setAccessible(true);
//        System.out.println(field.get(reflexx) instanceof Iterable);
//
//        Object o = field.get(reflexx);
//
//        forEach(o);

        AAA aa = new AAA();
        BB bb = new BB();

        aa.name = "aa";
        bb.name = "bb";


        Integer[] a = {1, 2, 3, 4, 5};
        System.out.println(Arrays.stream(a).anyMatch(w -> w == 2));

    }

    private static Object forEach(Object o) {
        if (o instanceof Collection) {
            Iterable<Object> iterable = (Iterable) o;
            AtomicInteger i = new AtomicInteger();
            iterable.forEach(e -> {
                if (forEach(e) != null) {

                }
                i.getAndIncrement();
            });
            return null;
        }
        return o;
    }
}
